package practice;

import java.io.*;
import java.util.Properties;

/**
 * @Author:DarknessShadow
 * @description:适配器（做中间功能转换）
 * @date 2020/5/9 14:04
 */
public class FileProperties extends Properties implements FileIO {

    public FileProperties() {
    }

    @Override
    public void readFromFile(String fileName) throws IOException {
        load(new FileInputStream(new File(fileName)));
        System.out.println(getProperty("year"));
    }

    @Override
    public void writeToFile(String fileName) throws IOException {
        OutputStream out = new FileOutputStream(fileName);
        store(out, "properties增强型适配器");
    }

    @Override
    public void setValue(String key, String value) {
        setProperty(key,value);
    }

    @Override
    public String getValue(String key) {
        return getProperty(key);
    }
}
